﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace HZ.Supervise.Web.Common
{
    public partial class FindHospital : BasePage
    {
        string aid;
        protected void Page_Load(object sender, EventArgs e)
        {aid = Request["aid"];
            dataBind();
            
        }

        /// <summary>
        /// 数据绑定
        /// </summary>
        private void dataBind()
        {
            HZ.Supervise.IBLL.IBLL_PreWarning pre = HZ.Supervise.BLLFactory.IBLL_PreWarning();
            string where = "";
            string areaID = "";

            int i;
            if (!string.IsNullOrEmpty(this.txtHosName.Text))
            {
                where = this.txtHosName.Text;
            }
            if (string.IsNullOrEmpty(aid))
            {
                if (!CurrentAccount.GetUser().Org.Area.AreaID.Equals(Constants.CURRENT_DEPLOY_AREAID))
                {
                    areaID = CurrentAccount.GetUser().Org.Area.AreaID;
                }
            }
            else
            {
                if (aid.Equals("530101"))
                {
                    areaID = CurrentAccount.GetUser().Org.Area.AreaID;
                }
                else
                {
                    areaID = "X" + aid;
                }
              
            }
          
            DataTable dt = pre.GetHospital(where, areaID, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out i);
            AspNetPager1.RecordCount = i;
            gvwHosList.DataSource = dt;
            gvwHosList.DataBind();
        }


        protected void gvwselect_RowDataBound(object sender, GridViewRowEventArgs e)
        {

        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            dataBind();
        }

        protected void btnQery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            dataBind();
        }
    }
}
